using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections;


public partial class Motivos_Config : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string usuario = Session["usuario"].ToString();
        lb_usuario.Text = usuario;
        imLogo.ImageUrl = Session["logo"].ToString();
        lb_cargado.Visible = false;
    }
    protected void cb_verde_CheckedChanged(object sender, EventArgs e)
    {

    }

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {

    }
    protected void img_cargarImagen_Click(object sender, ImageClickEventArgs e)
    {
        if (FileUpload1.HasFile)
        {

            string fileName = Server.HtmlEncode(FileUpload1.FileName);

            // Get the extension of the uploaded file.
            string extension = System.IO.Path.GetExtension(fileName);
            if (extension.ToLower() == ".jpg" || extension.ToLower() == ".png" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".gif")
            {
                FileUpload1.SaveAs(MapPath("~/ImagenesProductos/") + FileUpload1.FileName);
                imgLogo.ImageUrl = "~/ImagenesProductos/" + FileUpload1.FileName;
                pathImagen.Text = imgLogo.ImageUrl;

            }
            else
            {
                Response.Write("<SCRIPT language=\"javascript\"> window.alert(\"" + "El archivo debe ser una imagen" + "\") </SCRIPT>");
            }

        }




    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       
    }
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/Administrador/Configuracion.aspx");
    }
    protected void Button1_Click(object sender, ImageClickEventArgs e)
    {
 string logo = pathImagen.Text;
        string estilo = pathIconos.Text;
        SqlConnection conexion = null;
        try
        {
            conexion = Conexion.CrearConexion();
            IDbCommand comando = Conexion.CrearComando(conexion);
            comando.CommandText = "insert into Config " +
                " (logo,estilo) " +
                " values (@logo,@estilo) ";
            comando.Parameters.Add(Conexion.CrearParametro("@logo", logo));
            comando.Parameters.Add(Conexion.CrearParametro("@estilo", estilo));

            comando.ExecuteNonQuery();

            lb_cargado.Visible = true;

        }
        finally
        {
            conexion.Dispose();
        }
    }
    
    protected void imPersona_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/Login.aspx");
    }
}
